﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Aishow.Website
{
    /// <summary>
    /// DiscussListHandler 的摘要说明
    /// </summary>
    public class DiscussListHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            var videoId = context.Request.QueryString["id"];
            var pageNumber = Convert.ToInt32(context.Request.QueryString["pageNumber"]);
            var pageSize = Convert.ToInt32(context.Request.QueryString["pageSize"]);
            IDiscussManager manager = new DiscussManager();
            var list = manager.QueryDiscusses(videoId, pageNumber, pageSize);
            var json = JsonConvert.SerializeObject(list, new UnixDateTimeConverter());


            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.Response.End();


        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}